<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="d1"><br>
<input type="text" id="d2">
<input type="button" value="加" onclick="f1()">
<input type="button" value="减" onclick="f2()"><br>
<input type="button" value="乘" onclick="f3()">
<input type="button" value="除" onclick="f4()">
<h1>结果:<span></span></h1>
<script>
    function f1() {
        let i1=document.querySelector("#d1");
        let i2=document.querySelector("#d2");
        let s=document.querySelector("span")
        if (isNaN(i1.value) && isNaN(i2.value)){
            s.innerText="输入错误";
        }else {
            s.innerText=parseFloat(i1.value)+parseFloat(i2.value);
        }
    }
    function f2() {
        let i1=document.querySelector("#d1")
        let i2=document.querySelector("#d2")
        let s=document.querySelector("span")
        if (isNaN(i1.value) && isNaN(i2.value)){
            s.innerText="输入错误";
        }else {
            s.innerText=parseFloat(i1.value)-parseFloat(i2.value)
        }
    }
    function f3() {
        let i1=document.querySelector("#d1")
        let i2=document.querySelector("#d2")
        let s=document.querySelector("span")
        if (isNaN(i1.value) && isNaN(i2.value)){
            s.innerText="输入错误"
        }else {
            s.innerText=(i1.value)*(i2.value);
        }
    }
    function f4() {
        let i1=document.querySelector("#d1")
        let i2=document.querySelector("#d2")
        let s=document.querySelector("span")
        if (isNaN(i1.value) && isNaN(i2.value)){
            s.innerText="输入错误"
        }else {
            s.innerText=(i1.value)/(i2.value)
        }
    }

</script>
</body>
</html>